/*
	author: TangQiao , Wind @ Beijing Normal University

	problem name: Rails
	
	source : PKU Online Judge
	
	problem type: 模拟 
	
	problem description: 模拟进栈和出栈过程,看是否能够按题目所说顺利输出. 
	
	problem solution: 模拟 
	
	date : 2005.9.22
	
*/
#include <stdio.h>
#include <string.h>

int stack[1010];
int n;
int in[1010], a;
int p_in;
int top;
bool first = true;
int main()
{
    int i;
    while (1)
    {
        scanf("%d", &n);
        if (n == 0) break;
        
        if (first) first = false;
        else printf("\n");
        while (1)
        {
            scanf("%d", in+1);
            if (in[1] == 0) break;
            for (i=2; i<=n; ++i)
            	scanf("%d", in+i);
            	
           	memset(stack, 0, sizeof(stack));
         
            p_in = 1;
            top = 1;
            for (a=1; a<=n; ++a)
            {
                stack[top++] = a;
                while (stack[top-1] == in[p_in] && top > 0 && p_in<=n)
                {
                    top --;
                    p_in ++;
                }    

            }    

            if (top ==1) printf("Yes\n");
            else printf("No\n");
        
        }    
        
        
    }    
    
    
    return 0;
}    